package CanvaWeb.CanvaWeb.Repository;

import CanvaWeb.CanvaWeb.pojo.Room;
import org.springframework.data.jpa.repository.JpaRepository;
import CanvaWeb.CanvaWeb.pojo.User;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface UserRepository extends JpaRepository<User, Long> {
    User findByUsername(String username);
    boolean existsByUsername(String username);
    User findByEmail(String email);
    User findByPhone(String phone);
    boolean existsByEmail(String email);
    boolean existsByPhone(String phone);
    @Query("SELECT u FROM User u JOIN RoomMember rm ON u.id = rm.userId WHERE rm.roomId = :roomId")
    List<User> getUsersInRoom(@Param("roomId") Long roomId);
    List<User> findByRoomId(Long roomId);
    List<User> findByRoom(Room room);
}

